package top.dancun.eascourse.feign.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.dancun.common.utils.R;
import top.dancun.eascourse.entity.TeacherEntity;
import top.dancun.eascourse.feign.BaseInfoFeign;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class BaseInfoFeignService{
    @Autowired
    BaseInfoFeign baseInfoFeign;
    //TODO 后期feign业务逻辑转移到此
//
//    public R getClassList(Map<String, Object> params) {
//        return null;
//    }
//
//

//
//
//    public R getClassByIds(List<Integer> ids) {
//        return null;
//    }


    public Map<Integer,String> listRoomByIds(List<Integer> ids) {
        R r = baseInfoFeign.listRoomByIds(ids);
        Map<Integer,String> roommap = new HashMap<>();
        if ("20000".equals(r.get("code").toString())) {
//            远程调用返回类型为list或者map
            List<Map<String, Object>> roomList = (List<Map<String, Object>>) r.get("data");
            roomList.forEach(map -> {
                Integer id = Integer.parseInt(String.valueOf(map.get("id")));
                String roomName = String.valueOf(map.get("parentName"))+"-"+String.valueOf(map.get("roomNumber"));
                roommap.put(id,roomName);
            });
        }
        return roommap;
    }
}
